package cn.buk.tms.entity.misc;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.persistence.UniqueConstraint;

/**
 * 数据字段导出模板
 * @author yfdai
 */
@Entity
@Table(name = "data_field_export_template",
    uniqueConstraints=@UniqueConstraint(name="uk_data_export_template",	columnNames={"enterprise_id", "template_no"} ))
public class DataFieldExportTemplate {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private int id;

  @Column(name = "enterprise_id")
  private int enterpriseId;

  /**
   * 模板编号
   */
  @Column(name = "template_no")
  private int templateNo;

  /**
   * 模板名称
   */
  private String name;

  @OneToMany(mappedBy = "template", cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
  private List<DataFieldExportInfo> exportFields;


  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  @Temporal(TemporalType.TIMESTAMP)
  @Column(name = "create_time", insertable = false, updatable = false)
  private Date createTime;



  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }


  public Date getCreateTime() {
    return createTime;
  }

  public void setCreateTime(Date createTime) {
    this.createTime = createTime;
  }


  public int getEnterpriseId() {
    return enterpriseId;
  }

  public void setEnterpriseId(int enterpriseId) {
    this.enterpriseId = enterpriseId;
  }

  public int getTemplateNo() {
    return templateNo;
  }

  public void setTemplateNo(int templateNo) {
    this.templateNo = templateNo;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public List<DataFieldExportInfo> getExportFields() {
    if (exportFields == null) {
      exportFields = new ArrayList<>();
    }
    return exportFields;
  }

  public void setExportFields(List<DataFieldExportInfo> exportFields) {
    this.exportFields = exportFields;
  }
}
